<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
	</head>

	<body>
		<div class="am-g">
			{include file='../Common/hy_header.html'}
			<div class="am-u-md-8 am-u-end">
				<form class="am-form am-form-horizontal hy-js-form">
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">角色名</label>
						<div class="am-u-sm-9">
							<input type="text" name="role_name" value="{$user_info.role_name}" placeholder="角色名">
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">描述</label>
						<div class="am-u-sm-9">
							<textarea name="role_des">{$user_info.role_des}</textarea>
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">角色权限</label>
						<div class="am-u-sm-9">
							<table class="am-u-sm-12" border="1" cellpadding="2" style="border-color: #ccc;">
								<tbody>
								{foreach from=$action_list item=act}
									<tr>
										<td width="20%" style="padding-left:5px;">
											<input type="checkbox" name="action_list[]" value="{$act.action_id}" {if $act.check eq 1} checked {/if} class="act_box act_par_{$act.action_id}">{$act.action_list}
										</td>
										<td style="padding-left:5px;">
										{foreach from=$act.child item=kid}
											<div style="float:left;width:30%;margin-bottom:3px;margin-top:3px;">
												<input type="checkbox" name="action_mod[]" value="{$kid.mod_id}" {if $kid.check eq 1} checked {/if} class="act_box_{$act.action_id} act_child" data-id="{$act.action_id}">{$kid.mod_name}
											</div>
										{/foreach}
										</td>						
									</tr>
								{/foreach}
								</tbody>
							</table>
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<input type="hidden" name="id" value="{$id}" />
							<button type="button" class="am-btn am-btn-primary hy-js-submit">{$_L.SAVE}</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript">
			hy_submit('index.php?g=admin&m=admin&a={$action}');
		
			$(function(){
				$('.act_box').click(function(){
					var _this = $(this);
					var val = _this.val();
					var box = $('.act_box_'+val);
					var type = _this.attr("checked");
					box.each(function(){
						if(type == 'checked')
						{
							$(this).attr('checked', 'checked');	   
						}
						else
						{
							$(this).attr('checked', false);
						}
					});
				});
				
				$('.act_child').click(function(){
					var _this = $(this);
					var id = _this.attr("data-id");
					var box = $('.act_box_'+id);
					if(_this.attr('checked') == 'checked')
					{
						$('.act_par_'+id).attr('checked', 'checked');
					}
					else
					{
						var num = 0;
						box.each(function(){
							if($(this).attr('checked') == 'checked')
							{
								num++;
							}
						});
						
						if(num > 0)
						{
							$('.act_par_'+id).attr('checked', 'checked');
						}
						else
						{
							$('.act_par_'+id).attr('checked', false);
						}
					}
				});
			});
		</script>
	</body>

</html>